package gmu.xytxl.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import gmu.xytxl.service.IMaillistService;
import gmu.xytxl.service.impl.MaillistServiceImpl;


 


/**
 * Servlet implementation class Yhxx
 */
@WebServlet("/FindMaillist")
public class FindMaillist extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public FindMaillist() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		IMaillistService maillistService = new MaillistServiceImpl();
		String page = request.getParameter("page");
		String pagesize = request.getParameter("pagesize");
		String string = maillistService.findAllMaillistJson(page,pagesize);
		System.out.println(string);
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		response.getWriter().write(string);  
		response.getWriter().flush();
		
//		List<Xymd> list = xymdService.findAllXymd();
//		Xymd xymd = list.get(0);
//		request.setAttribute("xymd", xymd);
//		request.getRequestDispatcher("index.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
